package com.szcatic.ework.controller.system;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.szcatic.ework.service.system.MenuService;
import com.szcatic.ework.vo.system.MenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 菜单管理Controller
 * @author Administrator
 *
 */
@Controller
@RequestMapping(value="system/menu")
public class MenuController {

	@Autowired
	private MenuService menuService;

	@Autowired
	private HttpServletRequest request;
	
	@RequestMapping(value="")
	public String index() {
		return "system/menu";
	}

	@RequestMapping(value="queryMenuList")
	@ResponseBody
	public Map<String,Object> queryMenuList() {
		PageHelper.startPage(Integer.valueOf(request.getParameter("page")), Integer.valueOf(request.getParameter("limit")));
		List<MenuVo> menuVo= menuService.queryList();
		PageInfo<MenuVo> pageInfo=new PageInfo<MenuVo>(menuVo);
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("count", pageInfo.getTotal());
		map.put("data", pageInfo.getList());
		map.put("code", "0"); //成功的状态码
		map.put("msg", "");
		return map;
	}

}
